package org.example.ioc.pro1;

import org.example.ioc.pro1.bean.BankDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

//面向接口的类的实例的托管
public class App4_annotation_interface {
    public static void main(String[] args) {
        //1.创建Spring容器对象
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        //父类容器指向子类容器，可以不用类，用接口
        //BankMysqlDao bankMysqlDao = (BankMysqlDao) context.getBean("bankMysqlDao");
        BankDao bankDao = (BankDao) context.getBean("bankMysqlDao");
        bankDao.deposit();

        //复用实例名称
        bankDao = (BankDao) context.getBean("bankOracleDao");
        bankDao.deposit();



    }
}
